package ar.edu.itba.tp1.tpalan;


import java.util.List;

import ar.edu.itba.tp1.gps.api.GPSState;

/**
 * GPSState implementation.
 */
public class MyGPSState implements GPSState {
	private FillZoneBoard fillZoneBoard;
	
	public MyGPSState(FillZoneBoard fillZoneBoard) {
		this.fillZoneBoard = fillZoneBoard;
	}
	
	public boolean compare(GPSState state) {
		return this.equals(state);
	}
	
	public boolean isGoal() {
		return this.fillZoneBoard.hasOneColour();
	}
	
	public FillZoneBoard getFillZoneBoard() {
		return this.fillZoneBoard;
	}

	/**
	 * Propagates through the board the colour
	 */
	public GPSState changeColour(Colour targetColour) {
		FillZoneBoard fillZoneBoard = this.fillZoneBoard.clone();
		
		fillZoneBoard.propagateColour(targetColour);
		
		return new MyGPSState(fillZoneBoard);
	}
	
	public int getColourCount(){
		return this.fillZoneBoard.getColourCount();
	}
	
	public int getFarClusterDistance() {
		return fillZoneBoard.getFarClusterDistance();
	}
	
	public List<Colour> getNeighboursColours(){
		return fillZoneBoard.getNeighboursColours();
	}
	
	public int getBoardSizeToComplete(){
		return fillZoneBoard.getDimension()-fillZoneBoard.getMainClusterSize();
	}
	
	@Override
	public String toString() {
		return fillZoneBoard.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((fillZoneBoard == null) ? 0 : fillZoneBoard.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MyGPSState other = (MyGPSState) obj;
		if (fillZoneBoard == null) {
			if (other.fillZoneBoard != null)
				return false;
		} else if (!fillZoneBoard.equals(other.fillZoneBoard))
			return false;
		return true;
	}

	@Override
	public boolean isGoalState() {
		return isGoal();
	}

	@Override
	public Integer[][] getValues() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public GPSState copyState() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void addValue(int i, int j, Integer value) {
		// TODO Auto-generated method stub
		
	}

}
